// import { Inject,Post,Query} from "@nestjs/common"
import { Controller,Inject,Post,Query,Get, Param, Body} from '@nestjs/common';

import {WorksService} from "./works.service"

@Controller('works')
export class WorksController {
    constructor(private worksService:WorksService ){}

    @Post("upload")
    works(@Body() body){
        // console.log(body)
        if(!body.image){
            body.image = []
        }
        body.image = JSON.stringify(body.image)
        // console.log(body)
        return  this.worksService.addWorks(body)
        // return {
        //     code:200,
        //     mes:"发布成功",
        //     // body
        // }
       
    }

    //前台普通获取作品数据
    @Get("getAllWorks")
    getAllWorks(){
       return this.worksService.getAllWorks()
    }

    @Get("getTeamData")
    getTeamData(@Query() que){
        // console.log(que)
        // return {
        //     code:200,
        //     que
        // }
        return  this.worksService.getteamData(que.teamId,que.examine)
      
    }

    // 后台管理的获取作品的数据
    @Get("getAllWorksData")
    getAllWorksData(@Query() que){
        if(!que.take || !que.current){
            return {
                code:400,
                mes:"还没有传入数据呢",
                data:[],
                count:0
            }
        }  

       return this.worksService.getAllworksData(que)
    }

    // 获取我个人的任务
    @Get("getMyTask")
    getMyTask(@Query() que){
        if(!que.take || !que.current){
            return {
                code:400,
                mes:"还没有传入数据呢",
                data:[],
                count:0
            }
        }  
      return  this.worksService.getMyTask(que)
    }

    @Post("bulkForward")
    bulkForward(@Body() body){
        // console.log(body)

        return this.worksService.handlesBulkData(body)
    }

}
